package ewa.big.utilities;

import java.io.Serializable;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import javax.faces.application.Application;
import javax.faces.context.FacesContext;

/**
 * <b>Web Engineering - UE3</b>
 * <p>
 *
 * This class implements the utilities for the "Mensch aergere Dich nicht" game.
 */
public class Utility implements Serializable {

    /**
     * Get the text assigned to the specified key.
     * 
     * @param ctx           the context object.
     * @param bundleName    the name of the resource bundle.
     * @param key           the key.
     * @return the string assigned to the key.
     */
    public static String getResourceText(
      FacesContext ctx, 
      String       bundleName, 
      String       key) 
    {
        String text;
        try {
            Application app = ctx.getApplication();
            ResourceBundle bundle = app.getResourceBundle(ctx, bundleName);
            text = bundle.getString(key);
        } catch (MissingResourceException e) {
            return "???" + key + "???";
        }

        return text;
    } // end getResourceText
    
} // end of the class Utility
